package com.woniuxy.service.impl;

import com.woniuxy.dao.IAuthDao;
import com.woniuxy.domain.User;
import com.woniuxy.service.IAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Service
@Transactional
public class AuthServiceImpl implements IAuthService {

    @Autowired
    private IAuthDao iAuthDao;

    @Override
    public boolean verify(String userName, String userPassword) {
        User user = new User();
        user.setUsername(userName);
        user.setPassword(userPassword);
        Optional<User> optional = iAuthDao.findOne(Example.of(user));
        if (optional.isPresent()) {
            return true;
        }
        return false;
    }
}
